package com.sicheng.lc.周赛.分类.模拟;

import java.util.HashMap;

/**
 * @author zsc
 * @version 1.0
 * @date 2022/8/8 23:33
 */
public class 任务调度器II {
    //https://leetcode.cn/problems/task-scheduler-ii/
    static long Temp = -0x3f3f3f3f;

    public long taskSchedulerII(int[] tasks, int space) {
        long day = 0;

        HashMap<Integer, Long> map = new HashMap<>();
        for (int t : tasks) {
            long v = map.getOrDefault(t, Temp);
            day = Math.max(day, v + space) + 1;
            map.put(t, day);
        }
        return day;

    }
}
